<template>
	<view class="wrap">
		<view class="top" :style="{backgroundImage:`url(${$IMG_URL}/assets/income-bg.png)`}">
			<view class="status-bar"></view>
			<view class="tabs s-flex-r-s-c">
				<view class="tab s-flex-c-c-c" @click="tabHandle(item)" :class="current==item.id?'active':''" v-for="item in tabs" :key="item.id">
					<text>{{item.name}}</text>
				</view>
			</view>
		</view>
		<view class="one s-flex-c-s-c" v-if="one&&one.avatar">
			<image class="avatar" :src="one.avatar" mode=""></image>
			<image class="no" src="/static/images/indexnew/j1.png" mode=""></image>
			<view class="name">{{one.nickname}}</view>
			<view class="money">
				+{{one.total_money}}
			</view>
		</view>
		<u-empty :margin-top="100" v-else text="暂无数据" mode="history"></u-empty>
		<view class="list" v-if="list2&&list2.length">
			<view class="item s-flex-r-b-c" v-for="(m,i) in list2" :key="m.id">
				<view class="l s-flex-r-s-c">
					<image v-if="i==0" class="no" src="/static/images/indexnew/j2.png" mode=""></image>
					<image v-else-if="i==1" class="no" src="/static/images/indexnew/j3.png" mode=""></image>
					<view v-else class="no-box s-flex-c-c-c">
						<text>{{i+2}}</text>
					</view>
					<image class="avatar"  :src="m.avatar" mode=""></image>
					<view class="time">{{m.nickname}}</view>
				</view>
				<view class="money">
					+{{m.total_money}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current:"lastday",
				one: {},
				list2: [],
				// lastday=昨天,month=本月,year=本年
				tabs:[
					{
						name:'昨日',
						id:'lastday'
					},
					{
						name:'本月',
						id:'month'
					},
					{
						name:'本年',
						id:'year'
					},
				]
			};
		},
		onLoad() {
			this.getList()
		},
		methods:{
			getList(){
				this.$http('user.userRanking', {date:this.current}).then(res => {
					if(res.data&&res.data.length){
						this.one = res.data[0]
						this.list2=res.data.slice(1)
						console.log('this.list2: ', this.list2)
						
					}
				});
			},
			tabHandle(item){
				this.current = item.id;
				this.getList()
			}
		}
	}
</script>

<style lang="scss">
	.list{
		background: #FFFFFF;
		padding: 30rpx 20rpx;
		width: 686rpx;
		margin: 0 auto;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin-top: 20rpx;
		.item{
			margin-bottom: 40rpx;
			.l{
				.no{
					width: 36rpx;
					height: 40rpx;
					margin-right: 20rpx;
				}
				.no-box{
					margin-right: 20rpx;
					width: 36rpx;
					height: 36rpx;
					background: #D9D9D9;
					border-radius: 16rpx;
					font-weight: 500;
					font-size: 20rpx;
					color: #333333;
				}
				.avatar{
					width: 64rpx;
					height: 64rpx;
					margin-right: 16rpx;
				}
				.time{
					font-weight: 500;
					font-size: 28rpx;
					color: #333333;
					line-height: 33rpx;
				}
			}
			.money{
				font-size: 28rpx;
				color: #EB5C20;
				line-height: 33rpx;
			}
		}
	}
	.empty{
		margin-top: 100rpx;
	}
	.one{
		width: 686rpx;
		height: 354rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0 auto;
		margin-top: -68rpx;
		padding-top: 68rpx;
		position: relative;
		.no{
			width: 64rpx;
			height: 74rpx;
			position: absolute;
			top: 30rpx;
			left: 256rpx;
		}
		.avatar{
			width: 152rpx;
			height: 152rpx;
			margin-bottom: 14rpx;
		}
		.name{
			font-weight: 400;
			font-size: 28rpx;
			color: #333333;
			line-height: 40rpx;
		}
		.money{
			margin-top: 4rpx;
			font-weight: 600;
			font-size: 36rpx;
			color: #EB5C20;
			line-height: 50rpx;
		}
	}
.top{
	.status-bar {
		height: var(--status-bar-height);
		width: 100%;
	}
	
	width: 750rpx;
	background-position: 0 0;
	background-repeat: no-repeat;
	background-size: 100% 100%;
	height: 400rpx;
	.tabs{
		padding: 44rpx 32rpx;
		.tab{
			width: 112rpx;
			height: 48rpx;
			background: rgba(255,255,255,0.1);
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			margin-right: 32rpx;
			font-weight: 400;
			font-size: 28rpx;
			color: #FFFFFF;
			line-height: 33rpx;
		}
		.active{
			background: #FFFFFF;
			color: #EB5C20;
		}
	}
}
.s-flex-wrap{
	  flex-wrap: wrap;
  }
  .s-flex-r-s-s {
    display: flex;
  }
  .s-flex-r-s-c {
    display: flex;
    align-items: center;
  }
  .s-flex-r-e-c {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .s-flex-r-c-c {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .s-flex-r-b-c {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .s-flex-r-b-s {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  .s-flex-r-b-e {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }

  .s-flex-c-s-s {
    display: flex;
    flex-direction: column;
  }

  .s-flex-c-s-c {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
  }

  .s-flex-c-b-s {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
  }

  .s-flex-c-c-c {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .s-flex-c-s-e {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
  }
  .s-flex-c-e-c {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
  }
  .flex1{
	  flex: 1;
  }

</style>
